﻿<!DOCTYPE HTML>
<html>
<head>
<#include "/script.ftl">
<link rel="stylesheet" type="text/css" href="../static/eth/css/customer.css" />
<script type="text/javascript" src="../static/eth/js/jElass.js"></script>
<script type="text/javascript" src="../static/eth/js/jElassExec.js"></script>
<title>用户详情</title>
</head>
<body id="body" class="common_body">
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>账户
		<span class="c-gray en">&gt;</span> 用户管理
	</nav>
	<div class="page-container">
		<form id="form" action="list" autocomplete="off">
			<input type="text" style="display:none" name="pageIndex" id="pageIndex" value="${page.curIndex!''}"/>
			<input type="text" style="display:none" name="pageSize" id="pageSize" value="${page.pageSize!''}" />
			<input type="text" style="display:none" name="rowsCount" id="rowsCount" value="${page.rowsCount!''}" />
			<div class="customer_box text-c">
				<div class="customer_item1" style="margin-left:30px">
					<label>用户名</label>
					<input type="text" name="userName" value="${cond.userName!''}" onClick="UserId(userName,userId)" class="input-text radius">
					<input type="hidden" name="userId" id="userId" value="${cond.userId!''}">
				</div>
				<div class="customer_item1">
					<label>用户等级</label>
					<select name="vipLevel"  class="input-text radius text-overflow">
						<option value="">请选择等级</option>
						<option value="1" <#if '${cond.vipLevel!0}' ='1' >selected="selected"</#if> >普通员工</option>
						<option value="2" <#if '${cond.vipLevel!0}' ='2' >selected="selected"</#if> >部门管理员</option>
						<option value="3" <#if '${cond.vipLevel!0}' ='3' >selected="selected"</#if> >公司管理员</option>
					</select>
				</div>
				<div class="customer_item4"><input type="button" onClick="query_submit()" value="查询" name="" class="btn btn-primary radius"></div>
				<div class="f-r mr-20"><input type="button" onClick="user_edit('<center><strong>员工保存</strong></center>','editPage','800','550')" value="添加员工" name="" class="btn btn-primary radius"></div>
			</div>
			<div class="customer_box1"> 
				<table class="table table-hover panel panel-secondary">
					<thead class="panel-header text-c">
						<tr>
							<th width="10%">序号</th>
							<th width="10%">姓名</th>
							<th width="15%">用户名</th>
							<th width="15%">手机号</th>
							<th width="10%">部门</th>
							<th width="10%">角色</th>
							<th width="30%">操作</th>
						</tr>
					</thead>
					<tbody class="panel-body text-c">
						<#list page.items! as user>
							<tr ondblclick="user_edit('<center><strong>员工保存</strong></center>','editPage?userId=${user.userId!}','800','550')">
								<td>${page.pageSize * (page.curIndex-1) + user_index+1}</td>
								<td>${user.userName!''}</td>
								<td>${user.userCode!''}</td>
								<td>${user.phone!''}</td>
								<td>${(user.deptName)!''}</td>
								<td>${user.roleName!''}</td>
								<td>
									<input type="button" value="编辑" onClick="user_edit('<center><strong>员工保存</strong></center>','editPage?userId=${user.userId!}','800','550')" class="btn btn-primary radius">
									<input type="button" value="删除" onClick="user_delete('delete?userId=${user.userId!}')" class="btn btn-danger radius ml-10">
								</td>
							</tr>
						</#list>
					</tbody>
				</table>
			</div>
			<div id="div" class="cl">
				<div id="Pagination" class="pagination mt-20"></div>
			</div>
		</form>
		<div  class="customer_content others_div">
		</div>
	</div>
</body>
<script>
function query_submit(){
	$("div.customer_item1").find("input[type='hidden']").each(function(index,dom){
		if($(dom).prev().val() == ''){
				$(dom).val('');
		}				
	});
	$('#pageIndex').val(1);
	$('#form').submit()
}

function user_edit(title,url,w,h){
	layer_show(title,url,w,h);	
}

function user_delete(urlStr){
	if(!confirm("确定要删除？")){
		return;
	}
	$.ajax({
		type : 'get',  
		contentType : 'application/json',  
		url : urlStr,  
		success : function(data) {
			var rsult = jQuery.parseJSON(data);
			if (rsult.success) {
				alert("删除员工成功！");
				window.location.reload();
			} else {
				alert("删除员工失败!" + rsult.message);
			}
 		},  
		error : function(data) {  
        	alert("系统错误！")  
		}
	});
}
</script>
</html>